#include<bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define crap ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lli long long
#define pa pair<int,int>
#define pal pair<lli,lli>
#define vi vector< int >
#define vli vector< lli >
#define vpa vector< pa >
#define vpal vector< pal >
#define fi first
#define se second
#define pb push_back
#define pp pop_back

#define nl cout<<"\n"
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define debug1(x) cout<<#x<<" "<<x;nl
#define debug2(x,y) cout<<#x<<" "<<x<<", "<<#y<<" "<<y;nl
#define debugA(v) for(int i:v) cout<<i<<" ";nl
#define max3(x,y,z) max(max(x,y),z)
#define min3(x,y,z) min(min(x,y),z)

lli modpw(lli n,lli p)
{
    if(!p)
        return 1;
    if(p&1)
        return (modpw(n,p-1)*n)%mod;
    lli t=modpw(n,p>>1);
    return (t*t)%mod;
}

int main(int argc, char **argv)
{
    crap;
    int m;
    cin>>m;

    vli dp(m+1);
    dp[1] = 0;

    vector< vi > fact(m+1);
    fact[1].pb(1);
    for(int i=1;i<=m;i++)
        for(int j=2*i;j<=m;j+=i)
            fact[j].pb(i);

    FOR(i,m)
    {
        dp[i+1] = m;
        FOR(j,m)
            if((j+1)%(i+1))
                dp[i+1] += dp[__gcd(j+1,i+1)],dp[i+1]%=mod;
        dp[i+1]*=modpw(m-m/(i+1),mod-2), dp[i+1]%=mod;
    }
    lli ans = 0;
    FOR(i,m)
        ans+=1+dp[i+1],ans%=mod;
    ans*=modpw(m,mod-2),ans%=mod;
    cout<<ans<<endl;
}